﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace Takkou.Language
{
    public class RepeatUntil : Statement
    {
        public LogicExpression Condition { get; private set; }
        public Statement Stat { get; private set; }

        public RepeatUntil(Statement block, LogicExpression condition)
        {
            Stat = block;
            Condition = condition;
        }

        public override void start()
        {
            Stat.start();
        }

        public override bool execute()
        {
            // check if the block execution has finished
            if (Stat.execute() == false)
            {
                Stat.start();
            }
            return !Condition.get();  // return true while Condition has not yet been reached
        }
    }

}
